package com.bocom.dao;

import java.util.List;

import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.SessionFactory;




import org.springframework.stereotype.Repository;

import com.bocom.entity.User;
@Repository
public class UserDAO {

	private SessionFactory sessionFactory;

	public void setSessionFactory(SessionFactory sessionFactory) {
		System.out.println("设置SessionFactory"+this);
		this.sessionFactory = sessionFactory;
	}

	public SessionFactory getSessionFactory() {
		return sessionFactory;
	}

	public List<User> getAllUser(){
		if(this.sessionFactory==null)
		{
			System.out.println("SessionFactory is null"+this);
			return null;
		}
		String hsql="from user";
		Session session = sessionFactory.getCurrentSession();
		Query query = session.createQuery(hsql);	
		return query.list();
	}
	
}
